rm(list=ls())
pacman::p_load(ggplot2, sf, usmap, rnaturalearthdata, maps)
setwd('put_your_wd_here')

df <- read_csv('datasets/list_of_shootings_geocodes.csv')
points <- data.frame(lon = as.numeric(df$lon),
                     lat = as.numeric(df$lat),
                     include = df$top10) %>%
  na.omit()

transformed_data <- usmap_transform(points[,1:2])
transformed_data$include <- points$include

map <- plot_usmap(color='grey60') + 
  scale_fill_continuous() + 
  theme(legend.position = "right") + 
  theme(panel.background = element_blank()) +
  geom_point(data = transformed_data[transformed_data$include==0,], 
             aes(x = x, y = y), 
             color = "red",
             shape=3,
             size =4) +
  geom_point(data = transformed_data[transformed_data$include==1,], 
             aes(x = x, y = y), 
             color = "blue",
             shape=4,
             size =4)
map
ggsave(map, width=10, height=7, file='figures/map_shootings.pdf')
